import Vue from 'vue'
import VueRouter from 'vue-router'


import loginRoutes from '@/views/logins/route'
import errorRoutes from '@/views/errorpage/route'

Vue.use(VueRouter)


const routes = [
    {
        path: "/",
        redirect: "/login"
    },
    ...loginRoutes,
    ...errorRoutes,
    {
        path: "/main",
        name: "main",
        component: () => import("@/views/main/index.vue"),
        //  重定向，进入系统时定位到首页home
        redirect: "/main/home",
        //   嵌套路由：
        children: [
            {
                path: "home",
                name: "home",
                component: () => import("@/views/home/home.vue"),
            },
            {
                path: "mine",
                name: "mine",
                component: () => import("@/views/mine/mine.vue")
            },
            {
                path: "dormAdmin",
                name: "dormAdmin",
                component: () => import("@/views/dormAdmin/index.vue"),
                redirect: "/main/dormAdmin/dormAdmin-list",

                children: [
                    {
                        path: "dormAdmin-list",
                        name: "dormAdmin-list",
                        component: () => import("@/views/dormAdmin/list.vue")
                    },
                    {
                        path: "dormAdmin-add",
                        name: "dormAdmin-add",
                        component: () => import("@/views/dormAdmin/add.vue")
                    },
                ]
            },
            {
                path: "stuAdmin",
                name: "stuAdmin",
                component: () => import("@/views/stuAdmin/index.vue"),
                redirect: "/main/stuAdmin/stuAdmin-list",

                children: [
                    {
                        path: "stuAdmin-list",
                        name: "stuAdmin-list",
                        component: () => import("@/views/stuAdmin/list.vue")
                    },
                    {
                        path: "stuAdmin-add",
                        name: "stuAdmin-add",
                        component: () => import("@/views/stuAdmin/add.vue")
                    },
                ]
            },
            {
                path: "buildAdmin",
                name: "buildAdmin",
                component: () => import("@/views/buildAdmin/index.vue"),
                redirect: "/main/buildAdmin/buildAdmin-list",

                children: [
                    {
                        path: "buildAdmin-list",
                        name: "buildAdmin-list",
                        component: () => import("@/views/buildAdmin/list.vue")
                    },
                    {
                        path: "buildAdmin-add",
                        name: "buildAdmin-add",
                        component: () => import("@/views/buildAdmin/add.vue")
                    },
                ]
                // absAdmin
            },
            {
                path: "absAdmin",
                name: "absAdmin",
                component: () => import("@/views/absAdmin/index.vue"),
                redirect: "/main/absAdmin/absAdmin-list",

                children: [
                    {
                        path: "absAdmin-list",
                        name: "absAdmin-list",
                        component: () => import("@/views/absAdmin/list.vue")
                    },
                    {
                        path: "absAdmin-add",
                        name: "absAdmin-add",
                        component: () => import("@/views/absAdmin/add.vue")
                    },
                ]
                // absAdmin
            },

            {
                path: "communication",
                name: "communication",
                component: () => import("@/views/communication/communication.vue")
            },
        ]
    },

]

const router = new VueRouter({
    mode: 'hash',
    routes
})

export default router
